# Makefile for Simple TCP Client/Server

# Compiler
CXX = g++

# Compiler flags
# -std=c++11: Use C++11 standard
# -Wall: Enable most warnings
# -Wextra: Enable extra warnings
# -g: Generate debugging information
CXXFLAGS = -std=c++11 -Wall -Wextra -g

# Linker flags (none needed for this simple example)
LDFLAGS =

# Target executables
SERVER_EXEC = server
CLIENT_EXEC = client

# Source files
SERVER_SRC = TCPserver.cpp
CLIENT_SRC = TCPclient.cpp

# Default target: build both server and client
all: $(SERVER_EXEC) $(CLIENT_EXEC)

# Rule to build the server executable
$(SERVER_EXEC): $(SERVER_SRC) TCPserver.hpp
	$(CXX) $(CXXFLAGS) $(SERVER_SRC) -o $(SERVER_EXEC) $(LDFLAGS)
	@echo "Server executable '$(SERVER_EXEC)' created."

# Rule to build the client executable
$(CLIENT_EXEC): $(CLIENT_SRC) TCPclient.hpp
	$(CXX) $(CXXFLAGS) $(CLIENT_SRC) -o $(CLIENT_EXEC) $(LDFLAGS)
	@echo "Client executable '$(CLIENT_EXEC)' created."

# Rule to clean up generated files
clean:
	rm -f $(SERVER_EXEC) $(CLIENT_EXEC) *.o *~
	@echo "Cleaned up generated files."

# Phony targets (targets that don't represent files)
.PHONY: all clean